<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<%@ taglib uri="/mytag" prefix="yjd"%>
<div class="wrap">
	<div class="nav">
		<div class="return">
			<a href='<yjd:url url="/case/all"/>'>返回上一页</a>
		</div>
	</div>
	<!-- start -->
	<form method="post" enctype="multipart/form-data" class="J_ajaxForm" autocomplete="off" action='<yjd:url url="/case/add/submit"/>'>
		<div class="table_full">
			<table width="100%">
				<tr>
					<th width="200">案例名称:</th>
					<td>
						<input name="case_name" type="text" class="input length_5" value="${projectcase.case_name}">
						<input name="case_id" type="hidden" class="input length_5" value="${projectcase.case_id}">
					</td>
				</tr>
				<tr>
					<th>案例图片:</th>
					<td>
						<input name="case_pic" type="hidden" class="input length_5" value="${projectcase.case_pic}">
						<input name="case_imgfile" type="file" class="input length_5" >
					</td>
				</tr>
				<tr>
					<th width="200">关联类型:</th>
					<td>
						<select name="ref_type" id="ref_type" class="mr10" onchange="queryRelateContent()" >
							<option value="0">请选择</option>
							<option value="1">机构</option>
							<option value="2">项目</option>
							<option value="3" selected>医生</option>
						</select>
					</td>
				</tr>
				<tr>
					<th width="200">关联内容:</th>
					<td>
						<select name="ref_id" id="ref_id" class="mr10" >
							<c:forEach items="${ref_ids }" var="item">
								<option ${item.key==projectcase.ref_id?"selected='selected'":"" } value="${item.key }">${item.value }</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<th>案例简介:</th>
					<td><textarea name="case_content" rows="80" cols="100" >${projectcase.case_content}</textarea></td>
				</tr>
				<tr>
					<th>案例详情:</th>
					<td>
						<input name="detail_id" type="hidden" class="input length_5" value="${projectcase.detail_id}">
						<textarea name="detail" class="J_editor">${projectcase.strMap.detail}</textarea>
					</td>
				</tr>
			</table>
		</div>
		<input class="btn btn_submit J_ajax_submit_btn" type="submit" value="确认保存">
	</form>
</div>

<script>
    Upload_Config = {url : "${requestScope.FPWEB.rootPath }/resource/upload${requestScope.FPWEB.urlStuff}?type=4",uid : "${uid}",sign : "${sign}"};
    YJD.use('AppAdminCommon');

    function queryRelateContent() {
        $.ajax({
            type : "post",
            url : "${requestScope.FPWEB.rootPath }/case/relate/content${requestScope.FPWEB.urlStuff}",
            data: {"ref_type":$('#ref_type').val()},
            error : function(request) {
                alert("连接失败！");
            },
            success : function(result) {
                if (result.state == 1) {
                    $("#ref_id").empty();
                    idAndName = result.data.idAndName;
                    for(var id in idAndName){
                        $("#ref_id").append("<option value="+id+">"+idAndName[id]+"</option>")
                    }
                }
            }
        });
    };
    queryRelateContent();
</script>
